package com.zl.id.controller;

import java.util.List;

import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;
import com.jfinal.kit.JsonKit;
import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.tx.Tx;
import com.zl.id.common.base.BaseController;
import com.zl.id.dao.model.Qzz;
import com.zl.id.dao.model.Zhiw;

/**
 * 简历发布
 * 
 * @author Leon.Zhang
 *
 */
@Before(Tx.class)
public class JlmanageController extends BaseController {
	public void queryAllJlList() {
		List<Qzz> qzzList = Qzz.dao.find("select * from qzz ");
		renderJsonResult(qzzList);

	}

	/**
	 * 查询简历
	 */
	public void queryJl() {
		String userid = getPara("userid");
		Qzz qzz = Qzz.dao.findFirst("select * from qzz where userid = ? ", userid);
		renderJsonResult(qzz);

	}

	/**
	 * 新增简历
	 */
	public void addJl() {
		String jsonStr = HttpKit.readData(getRequest());
		Qzz qzz = JsonKit.parse(jsonStr, Qzz.class);
		String qzzid = qzz.getQzzid();
		if(StrKit.isBlank(qzzid)){
			qzz.setQzzid(StrKit.getRandomUUID());
			qzz.save();
		}else{
			qzz.update();
		}
		renderJsonSuccess();
	}

	/**
	 * 删除简历
	 */
	public void delJl() {
		String qzzid = getPara("qzzid");
		Qzz.dao.deleteById(qzzid);
		renderJsonSuccess();
	}
	/**
	 * 搜搜求职者
	 */
	public void qzzsearch(){
		String searchtext =getPara("searchtext")+"%";
		List<Qzz> qzzList = Qzz.dao.find(
				" select * from qzz  where   phonenum like ? or name like ? or sex like ? or email like ? or jnms like ? or zzjy like ? or grjs like ?",
				searchtext, searchtext,searchtext, searchtext, searchtext,searchtext,searchtext);
		renderJsonResult(qzzList);
	}
}
